from zhipuai import ZhipuAI
client = ZhipuAI(api_key="ab4891787863816b83378080d2d4c9ae.m8aFMCOqWWPPOJhz") # 请填写您自己的APIKey
response = client.chat.completions.create(
  model="glm-4",  # 填写需要调用的模型名称
    messages=[
        {"role": "user", "content": "你好！你叫什么名字"},
    ],
    stream=True,
    )

final_str = ""
for chunk in response:
    final_str += chunk.choices[0].delta.content
    # print(chunk.choices[0].delta)
    
print(final_str)